package com.basic;


import com.frame.struts.BaseBean;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.ConvertUtils;

import com.frame.struts.ActionContext;
import com.utils.*;

import java.util.Date;


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class StockChangeForm extends BaseBean {
    public StockChangeForm() {
    }
    
    static{
        ConvertUtils.register(new DateConverter(), Date.class);
    }
    
	StockChangeEntity sce = new StockChangeEntity();
	private String oldId="";
	public String addStockChange(){
		HttpServletRequest request = ActionContext.getActionContext().
			getRequest();
		HttpServletResponse response = ActionContext.getActionContext().
			getResponse();
		BasicFactory factory = new BasicFactory();
		String qyid = (String) request.getSession().getAttribute("session_qyid");
		sce.setQyid(qyid);
		sce.setOptdate(new Date());
		sce.setOptrid(CommUtil.getUserId(request));
		sce.setXh(factory.getNextXh("qy_gdbg", qyid));
		try{
			if (factory.addStockChange(sce)) {
			//System.out.println("wo zhi xing le!");
			    response.sendRedirect("/basic/queryStockMove.jsp");
			}
			else
			{
				response.sendRedirect("/basic/failed.jsp");
			}
		}
		catch (Exception e) {

		}
			return null;
	}
	public String modifyStockChange(){
		HttpServletRequest request = ActionContext.getActionContext().
			getRequest();
		HttpServletResponse response = ActionContext.getActionContext().
			getResponse();
		BasicFactory factory = new BasicFactory();
		String qyid = (String) request.getSession().getAttribute("session_qyid");
		sce.setQyid(qyid);
		sce.setOptdate(new Date());
		sce.setOptrid(CommUtil.getUserId(request));
		sce.setXh(factory.getNextXh("qy_gdbg", qyid));
		int tmp = Integer.parseInt(this.getOldId().trim());
		System.out.println("wo zhi xing le!"+tmp);
		factory.deleteStockChange(sce.getQyid(),tmp);
		try{
			if (factory.addStockChange(sce)) {
			//System.out.println("wo zhi xing le222!");
			    response.sendRedirect("/basic/queryStockMove.jsp");
		    }
			else
			{
				response.sendRedirect("/basic/failed.jsp");
			}
		}
		catch (Exception e) {
		}

			return null;
	}
	public String getOldId(){
		return this.oldId;
	}
	public void setOldId(String oldId){
		this.oldId=oldId;
	}

	/**
	 * @return sce.getReturns the bgsj.
	 */
	public java.sql.Date getBgsj() {
		return sce.getBgsj();
	}
	/**
	 * @param bgsj The bgsj to set.
	 */
	public void setBgsj(java.sql.Date bgsj) {
		sce.setBgsj(bgsj);
	}
	/**
	 * @return sce.getReturns the cze.
	 */
	public String getCze() {
		return sce.getCze();
	}
	/**
	 * @param cze The cze to set.
	 */
	public void setCze(String cze) {
		sce.setCze(cze);
	}
	/**
	 * @return sce.getReturns the gddm.
	 */
	public String getGddm() {
		return sce.getGddm();
	}
	/**
	 * @param gddm The gddm to set.
	 */
	public void setGddm(String gddm) {
		sce.setGddm(gddm);
	}
	/**
	 * @return sce.getReturns the gdmc.
	 */
	public String getGdmc() {
		return sce.getGdmc();
	}
	/**
	 * @param gdmc The gdmc to set.
	 */
	public void setGdmc(String gdmc) {
		sce.setGdmc(gdmc);
	}
	/**
	 * @return sce.getReturns the optdate.
	 */
	public Date getOptdate() {
		return sce.getOptdate();
	}
	/**
	 * @param optdate The optdate to set.
	 */
	public void setOptdate(Date optdate) {
		sce.setOptdate(optdate);
	}
	/**
	 * @return sce.getReturns the optrid.
	 */
	public String getOptrid() {
		return sce.getOptrid();
	}
	/**
	 * @param optrid The optrid to set.
	 */
	public void setOptrid(String optrid) {
		sce.setOptrid(optrid);
	}
	/**
	 * @return sce.getReturns the qyid.
	 */
	public String getQyid() {
		return sce.getQyid();
	}
	/**
	 * @param qyid The qyid to set.
	 */
	public void setQyid(String qyid) {
		sce.setQyid(qyid);
	}
	/**
	 * @return sce.getReturns the recstate.
	 */
	public String getRecstate() {
		return sce.getRecstate();
	}
	/**
	 * @param recstate The recstate to set.
	 */
	public void setRecstate(String recstate) {
		sce.setRecstate(recstate);
	}
	/**
	 * @return sce.getReturns the remark.
	 */
	public String getRemark() {
		return sce.getRemark();
	}
	/**
	 * @param remark The remark to set.
	 */
	public void setRemark(String remark) {
		sce.setRemark(remark);
	}
	/**
	 * @return sce.getReturns the xh.
	 */
	public int getXh() {
		return sce.getXh();
	}
	/**
	 * @param xh The xh to set.
	 */
	public void setXh(int xh) {
		sce.setXh(xh);
	}
	/**
	 * @return sce.getReturns the zze.
	 */
	public String getZze() {
		return sce.getZze();
	}
	/**
	 * @param zze The zze to set.
	 */
	public void setZze(String zze) {
		sce.setZze(zze);
	}
	public String getJzjgmc() {
		return sce.getJzjgmc();
	}

	public void setJzjgmc(String jzjgmc) {
		sce.setJzjgmc(jzjgmc);
	}
}
